package com.jackrain.nea.fc.dl.service;

import com.jackrain.nea.config.PropertiesConf;
import com.jackrain.nea.dl.common.utils.esutil.ElasticsearchUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import com.alibaba.fastjson.JSONObject;

/**
 * @author kangcong
 * 2018/09/11
 */
@Slf4j
@Component
public class PurOutBillIdPushEsService {

    @Autowired
    private ElasticsearchUtil elasticsearchUtil;

    @Autowired
    private PropertiesConf pconf;

    public void push(JSONObject data, Long id) {

        // 推送到es
        try {
            String esIndex = pconf.getProperty("DL_T_PUR_OUT_BILL_ID");
            elasticsearchUtil.addDataForce(data, esIndex, esIndex, id.toString());
        } catch (IOException e) {
//            log.error("推送到es发生异常：Id = " + id, e);
            log.error("PurOutBillIdPushEsService--error-->{}","推送到es发生异常：Id = " + id+ e);

        }

    }


}
